-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BadgeUnstyled] Add useBadge hook #30246
Conversation
@material-ui/core: parsed: +0.15% , gzip: +0.11% |
|
||
export interface BadgeUnstyledComponentsPropsOverrides {} | ||
|
||
export interface BadgeUnstyledTypeMap<P = {}, D extends React.ElementType = 'span'> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are moved to BadgeUnstyledProps.ts
@@ -258,7 +259,8 @@ async function generateProptypes( | |||
|
|||
prop.filenames.forEach((filename) => { | |||
const isExternal = filename !== tsFile; | |||
const implementedByUnstyledVariant = filename === unstyledFile; | |||
const implementedByUnstyledVariant = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed for extracting the default values from the BadgeUnstyledProps.ts
file.
@@ -42,36 +43,17 @@ const BadgeUnstyled = React.forwardRef(function BadgeUnstyled(props, ref) { | |||
overlap: overlapProp = 'rectangular', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if it makes sense to include this prop as it's not used in the unstyled component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, looks like we can move it to the styled component’s props.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done with 7674166
BREAKING CHANGE
BadgeUnstyled
does no longer support theoverlap
prop, it is now a prop only on theBadge
component inside@mui/material/Badge
.As the prop is not available, some of the classnames have been renamed:
In order to avoid breaking changes in the
@mui/material
package, the old classes are added in addition to the new ones. Also theoverlapCircular
andoverlapRectangular
classes keys are added, which can be used in combination with the new classes.The PR adds
useBadge
hook, that is used insideBadgeUnstyled
. It also updates thegenerateProps
script to consider*Props.ts
files when generating props.